﻿Imports System.Data
Imports System.Data.Odbc
Imports WSEntidades
Imports Utilerias
Imports Npgsql
Imports MySql.Data.MySqlClient
Public Class UbicacionFact
    Public Shared Function Build(ByVal dr As MySqlDataReader) As UbicacionBE
        Dim tmpUbicacion As UbicacionBE = New UbicacionBE()
        Try
            tmpUbicacion = buildInternal(dr.Item("IdUbicacion"),
                                         dr.Item("Clave"),
                                         dr.Item("Descripcion"),
                                         dr.Item("Status"))
            Return tmpUbicacion
        Catch ex As Exception
            Throw
        Finally
            tmpUbicacion = Nothing
        End Try
    End Function

    Public Shared Function buildInternal(ByVal idUbic As Object, ByVal clave As Object, ByVal descripcion As Object, ByVal estatus As Object) As UbicacionBE
        Dim tmpUbicacion As UbicacionBE = New UbicacionBE()
        Try
            With tmpUbicacion
                .IdUbicacion = convertDTFromDb.convertInt32(idUbic)
                .Clave = convertDTFromDb.ConvertString(clave)
                .Descripcion = convertDTFromDb.ConvertString(descripcion)
                Select Case convertDTFromDb.ConvertString(estatus)
                    Case "A"
                        .Status = ImpLocalBE.EstatusImpLocal.Activa
                    Case "I"
                        .Status = ImpLocalBE.EstatusImpLocal.Inactiva
                    Case Else
                        .Status = ImpLocalBE.EstatusImpLocal.Inactiva
                End Select
            End With
            Return tmpUbicacion
        Catch ex As Exception
            Throw
        Finally
            tmpUbicacion = Nothing
        End Try
    End Function
End Class
